package drds.configuration.web.module.admin;

import drds.configuration.db.Db;
import drds.configuration.mvc.aop.AllowNotLogin;
import drds.configuration.mvc.aop.interceptor.impl.LoginInterceptor;
import drds.configuration.mvc.core.Controller;
import drds.configuration.mvc.core.annotation.actionbind.ActionKey;
import drds.configuration.web.model.GroupDataSourceId;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @author caozhenghui@drds.team<330937205@qq.com>
 */
@ActionKey("/index")
public class IndexAction extends Controller {
    @AllowNotLogin
    @ActionKey("/index")
    public void index() {
        Db.setDataSourceId(GroupDataSourceId.DRDS_HOME);
        //Data.getListForModel(TableBusinessTypeModel.class, 1, 2, "select count(1) as count from table_business_type", "select * from table_business_type", new ArrayList<Object>(), new ArrayList<Object>());
        renderJsp("/index.jsp");
        return;
    }

    @AllowNotLogin
    @ActionKey("/index2")
    public void index2() {
        File file = new File("E:\\czh\\CentOS-6.8-x86_64-minimal.iso");
        renderFile(file, "压缩.iso");
        return;
    }

    @AllowNotLogin
    @ActionKey("/login")
    public void login() {
        setSessionAttribute(LoginInterceptor.LoginState, true);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", "0");
        map.put("msg", "登录成功");
        renderJson(map);
        return;
    }

}
